import pymysql

if __name__ == '__main__':
    coon = pymysql.connect(user="root", password="root", host="127.0.0.1", port=3306, database="test")
    cursor = coon.cursor()
    sql = "update stu set name = '老刘' where id = 1"
    cursor.execute(sql)
    # 提交事务
    coon.commit()
    # 释放资源
    cursor.close()
    coon.close()